/**
 * 
 */
package com.trungkent.smsbackup.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * @author TrungKent
 * 
 */
public class BoxnetUtils {

	private static Context mContext;
	private static BoxnetUtils instance;

	public static BoxnetUtils getInstance(Context context) {
		if (instance == null) {
			mContext = context;
			instance = new BoxnetUtils();
		}

		return instance;
	}
	
	public static void storeAuthToken(String authToken) {
		SharedPreferences prefs = mContext.getSharedPreferences(
				Constants.ACCOUNT_PREFS_NAME, 0);
		Editor edit = prefs.edit();
		edit.putString(Constants.BOX_NET_AUTH_TOKEN, authToken);
		edit.commit();
	}
	
	public static void storeUserName(String userName) {
		SharedPreferences prefs = mContext.getSharedPreferences(
				Constants.ACCOUNT_PREFS_NAME, 0);
		Editor edit = prefs.edit();
		edit.putString(Constants.BOX_NET_USER_NAME, userName);
		edit.commit();
	}
	
	public static String getAuthToken() {
		SharedPreferences prefs = mContext.getSharedPreferences(
				Constants.ACCOUNT_PREFS_NAME, 0);
		return prefs.getString(Constants.BOX_NET_AUTH_TOKEN, null);
	}
	
	public static String getAccountName() {
		SharedPreferences prefs = mContext.getSharedPreferences(
				Constants.ACCOUNT_PREFS_NAME, 0);
		return prefs.getString(Constants.BOX_NET_USER_NAME, null);
	}
}
